package com.aierkeji.call.cms.dao.jpa;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.aierkeji.call.cms.dao.BaseJPADao;
import com.aierkeji.call.cms.entity.AkjCallClueGroup;
import com.aierkeji.call.cms.entity.AkjCallUser;
import com.aierkeji.call.cms.entity.snap.AkjCallUserSnap;
import com.aierkeji.call.cms.entity.vo.SearchOptionsVo;

public interface AkjCallClueGroupDao extends BaseJPADao<AkjCallClueGroup, Long> {
	
	
	
	
	AkjCallClueGroup findByCreatedByAndIsDeleteAndId(AkjCallUserSnap CreatedBy,@Param("isDelete") boolean isDelete,@Param("id")Long id);

	@Modifying
	@Query("update AkjCallClueGroup set isRemove = 1, updatedBy.id =:#{#createdBy.id},updatedAt=:now  where id = :id and createdBy.id  =:#{#createdBy.id} and isRemove=0 ")
	int deleteClueGroup(@Param("id")Long id,AkjCallUserSnap createdBy,@Param("now")Date date);
	
	@Query("select new com.aierkeji.call.cms.entity.vo.SearchOptionsVo(groupName,id) from AkjCallClueGroup where (createdBy.id=:#{#createdBy.id} or :#{#createdBy.id} is null  ) and isDelete=0 order by groupName desc")
	List<SearchOptionsVo>  findSelectCallClueGroup(AkjCallUser createdBy);
}
